<template>
  <div class="loading-box" ref="loadingDom" v-if="isShow" @click="handleClickOnModel">
    <div class="loading-content">
      <template v-if="viewSrc">
        <img
             width="60%"
             :src="viewSrc"
             alt="loading"
        >
      </template>
      <template v-else>
        <p>暂无数据</p>
      </template>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isShow: true,
      viewSrc: '',
    };
  },

  methods: {
    close() {
      this.closeLoading();
    },
    closeLoading() {
      this.isShow = false;
      if (this.$refs.loadingDom) this.$refs.loadingDom.remove();
    },
    handleClickOnModel() {
      this.closeLoading();
    },
  }
};
</script>

<style lang="scss" scoped>
.loading-box {
  position: fixed;
  top: 0px;
  left: 0px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  user-select: none;
  background-color: rgba(14, 14, 14, .6);
  z-index: 9999;
  .loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #7bed9f;

    .icon {
      display: block;
      width: 60px;
      height: 60px;
      animation: rorated 1.5s linear infinite;
    }

    .tips {
      margin-top: 20px
    }
  }
}

@keyframes rorated {
  0% {
    transform: rotate(0deg)
  }

  50% {
    transform: rotate(180deg)
  }

  100% {
    transform: rotate(360deg)
  }
}

</style>
